/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package io.iec.edp.caf.context.spi;

import io.iec.edp.caf.autoconfigure.spi.AutoConfigurationExclusion;
import io.iec.edp.caf.commons.runtime.CafEnvironment;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wangyandong
 * @date 2021/09/23 16:00
 * @email wangyandong@inspur.com
 */
public class RedisExclusion implements AutoConfigurationExclusion {
    /**
     * 返回需要排除的自动配置列表
     *
     * @return
     */
    @Override
    public List<String> exclude() {
        List<String> list = new ArrayList<>();
        //如果是不启用Redis，则移除掉RedissonAutoConfigure类
        if ("false".equals(CafEnvironment.getEnvironment().getProperty("redis.enabled"))) {
            list.add("org.redisson.spring.starter.RedissonAutoConfiguration");
            list.add("org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration");
        }
        return list;
    }
}
